﻿using System;
using System.Diagnostics;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Common.Unity.Extensions.PropertyMapper.Testing.Objects;
using Common.Unity.Testing;
using Microsoft.Practices.Unity;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Testing.Core;
using Common.Unity.Extensions.PropertyMapper;

namespace Common.Unity.Extensions.PropertyMapper.Testing
{
	/// <summary>
	/// Summary description for PropertyMapperPolicyTests
	/// </summary>
	[TestClass]
	public class PropertyMapperPolicyTests : UnityContainerTestBase
	{
		[TestMethod]
		public void VerifyBasicNameMappedCorrectly()
		{
			EntityView view = Container.Resolve<EntityView>();
			Entity entity = Container.Resolve<Entity>( view );
			Assert.IsNotNull( entity.Description );
			Assert.AreEqual( view.Name, entity.Description );
		}

		[TestMethod]
		public void VerifyBasicNameMirroredMappedCorrectly()
		{
			Entity entity = Container.Resolve<Entity>();
			EntityView view = Container.Resolve<EntityView>( entity );
			Assert.IsNotNull( view.Name );
			Assert.AreEqual( entity.Description, view.Name );
		}

		[TestMethod, Owner( TestOwners.MichaelD_Bang )]
		public void VerifyReflectionPropertyMappedCorrectly()
		{
			EntityView view = Container.Resolve<EntityView>();
			Entity entity = Container.Resolve<Entity>( view );
			Assert.IsNotNull( entity.Child.Description );
			Assert.AreEqual( view.ChildDescription, entity.Child.Description );
		}

		[TestMethod]
		public void VerifyReflectionPropertyMirroredMappedCorrectly()
		{
			Entity entity = Container.Resolve<Entity>();
			EntityView view = Container.Resolve<EntityView>( entity );
			Assert.IsNotNull( view.ChildDescription );
			Assert.AreEqual( entity.Child.Description, view.ChildDescription );
		}

		[TestMethod, Owner( TestOwners.MichaelD_Bang )]
		public void VerifyBaseClassesNotProcessed()
		{
			EntityView view = Container.Resolve<EntityView>();
			SuperEntity entity = Container.Resolve<SuperEntity>( view );
			Assert.IsNull( entity.Description );
		}

		[TestMethod]
		public void VerifyBaseClassesProcessed()
		{
			EntityView view = Container.Resolve<EntityView>();
			SuperEntity entity = Container.Resolve<SuperEntity>( "ProcessBaseTypes", view );
			Assert.IsNotNull( entity.Description );
			Assert.AreEqual( view.Name, entity.Description );
		}
	}
}
